package com.bestcem.xm.ticket.controller.param.ticket.template;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

/**
 * 修改模板所需入参
 *
 * @author ympan <yuming.pan@idiaoyan.com>
 * @version v2.3
 * @date 2021/9/3 17:12
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UpdateTemplateParam {
    private String name;
    @JsonProperty("fields")
    private List<FieldInfo> fieldList;
    /**
     * 1：修改全部   2：仅修改名称
     */
    private Integer flag;

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    public static class SingleSelect {
        @JsonProperty("options")
        private List<Option> optionList;
        /**
         * content，该字段指的是source来源对应的汉字描述，该字段应该不会被使用，也无需做校验
         */
        private String content;
        private Integer source;

        @Data
        @NoArgsConstructor
        @AllArgsConstructor
        public static class Option implements Serializable {
            private String field;
            private Integer value;
        }
    }


    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    public static class Cascade {
        @JsonProperty("options")
        private List<Option> optionList;
        private Integer level;

        @Data
        @AllArgsConstructor
        @NoArgsConstructor
        public static class Option {
            private String id;
            private String pid;
            private String value;
        }
    }

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    public static class FieldInfo {
        private String name;
        private Integer type;
        /**
         * 如果不填默认为false
         */
        private Boolean required;
        @JsonProperty("single_select")
        private SingleSelect singleSelect;
        @JsonProperty("cascade")
        private List<Cascade> cascadeList;
        private String field;
    }
}
    